-
Notifications
You must be signed in to change notification settings - Fork 135
fix: Adapt new visualizer version #4025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
Reviewer's GuideRefactor plotting methods across mapdl and post modules to comply with the 0.10.0 visualizer API by explicitly handling new show() parameters, update the visualizer internals for argument validation, bump the visualization interface dependency, and add a corresponding changelog entry. Class diagram for updated plotting methods and MapdlPlotter.show()classDiagram
class MapdlPlotter {
+plot(meshes, points, labels, **kwargs)
+show(return_plotter=False, savefig=None, return_cpos=False, cpos=None, ...)
+switch_scene(pl)
}
class MapdlExtended {
+kplot(..., **kwargs)
+lplot(..., **kwargs)
+aplot(..., **kwargs)
+vplot(..., **kwargs)
+nplot(..., **kwargs)
+eplot(..., **kwargs)
}
class Post {
+_plot_point_scalars(..., **kwargs)
+_plot_cell_scalars(..., **kwargs)
}
MapdlExtended --> MapdlPlotter : uses
Post --> MapdlPlotter : uses
MapdlPlotter : +show() now validates return_cpos and return_plotter
MapdlExtended : +plotting methods now extract show() args explicitly
Post : +plotting methods now extract show() args explicitly
Class diagram for show() argument validation logicclassDiagram
class MapdlPlotter {
+show(return_plotter, savefig, return_cpos, cpos, ...)
}
MapdlPlotter : +show() raises ValueError if return_cpos and return_plotter are both True
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
for more information, see https://pre-commit.ci
@germa89 just so you know, this PR implies that users won't be able to pass show kwargs directly to PyVista except for the ones I manually exposed: This is caused because plot and show kwargs were being mixed in the visualizer and it causes errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @AlejandroFernandezLuces - I've reviewed your changes - here's some feedback:
- There’s a lot of repeated popping of
return_plotter
,return_cpos
,savefig
, andcpos
in each plot method—consider refactoring that into a shared helper or decorator to reduce duplication and maintenance surface. - Add a unit test for the new conflict check in
show()
to verify that passing bothreturn_plotter=True
andreturn_cpos=True
raises the intended ValueError. - I noticed inconsistent defaults when popping
return_cpos
(some methods useNone
, othersFalse
)—unify these defaults across all plot functions to ensure predictable behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There’s a lot of repeated popping of `return_plotter`, `return_cpos`, `savefig`, and `cpos` in each plot method—consider refactoring that into a shared helper or decorator to reduce duplication and maintenance surface.
- Add a unit test for the new conflict check in `show()` to verify that passing both `return_plotter=True` and `return_cpos=True` raises the intended ValueError.
- I noticed inconsistent defaults when popping `return_cpos` (some methods use `None`, others `False`)—unify these defaults across all plot functions to ensure predictable behavior.
## Individual Comments
### Comment 1
<location> `src/ansys/mapdl/core/post.py:695` </location>
<code_context>
+ return_cpos = kwargs.pop("return_cpos", False)
+ return_plotter = kwargs.pop("return_plotter", False)
+ savefig = kwargs.pop("savefig", None)
+ cpos = kwargs.pop("cpos", False)
with self._mapdl.save_selection:
# Select nodes to avoid segfault
</code_context>
<issue_to_address>
Inconsistent default value for 'cpos' parameter.
'cpos' defaults to False here but to None elsewhere. For consistency and to prevent type issues, use None as the default unless False is specifically required.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
cpos = kwargs.pop("cpos", False)
=======
cpos = kwargs.pop("cpos", None)
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/ansys/mapdl/core/mapdl_extended.py:472` </location>
<code_context>
+ return_plotter = kwargs.pop("return_plotter", False)
+ savefig = kwargs.pop("savefig", None)
+ cpos = kwargs.pop("cpos", None)
+ return_cpos = kwargs.pop("return_cpos", None)
pl = kwargs.get("plotter", None)
pl = MapdlPlotter().switch_scene(pl)
</code_context>
<issue_to_address>
Inconsistent default value for 'return_cpos' parameter.
Standardize the default value for 'return_cpos' across all methods, ideally to False, for consistency.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
return_cpos = kwargs.pop("return_cpos", None)
=======
return_cpos = kwargs.pop("return_cpos", False)
>>>>>>> REPLACE
</suggested_fix>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4025 +/- ##
==========================================
+ Coverage 89.05% 89.14% +0.09%
==========================================
Files 187 187
Lines 14970 15002 +32
==========================================
+ Hits 13331 13373 +42
+ Misses 1639 1629 -10 🚀 New features to boost your workflow:
|
I left a implementation question in here: ansys/ansys-tools-visualization-interface#306 (comment) |
I am going to wait for the next release that implements this comment. Closing for the moment. |
Description
Adapt PyMAPDL visualizer to 0.10.0 version of the ansys visualization tool.
Issue linked
Breaking change in visualization tool: ansys/ansys-tools-visualization-interface#306
Checklist
draft
if it is not ready to be reviewed yet.feat: adding new MAPDL command
)Summary by Sourcery
Adapt plotting methods to the updated visualization interface by removing deprecated keyword arguments from show() calls and upgrade the ansys-tools-visualization-interface dependency to 0.10.0.
Enhancements:
Build:
Summary by Sourcery
Adapt PyMAPDL plotting to the breaking changes in ansys-tools-visualization-interface 0.10.0 by removing deprecated **kwargs from show() calls, extracting and forwarding explicit parameters (return_plotter, return_cpos, savefig, cpos) in all plot methods, and bump the visualization-interface dependency accordingly.
Enhancements:
Build:
Documentation: